方永、南天紫云

道亦有道

用lua nginx module搭建一个二维码(qr code)生成器
2014年10月31日

如果有VPS,或者开源的路由器,安装一个nginx,

添加lua-nginx-module,再编译安装qrencode for lua ,用下面的lua代码,访问http://youip/qr?t=hello 就可以看到效果啦:

local qr = require "qrencode"
local args = ngx.req.get_uri_args()
 
ngx.header.content_type = 'image/png'
ngx.say(qr
    {
        text = args.t or "text",
        size = 5
    }
)